#ifndef CONFIGURATION_HPP
#define CONFIGURATION_HPP

#include <stdint.h>

struct SystemConfiguration {

    /* About motor. */
    float motor_position;          /* Current position of motor. */
    float motor_position_minimum;  /* Minimum position when motor working. */
    float motor_position_maximum;  /* Maximum position when motor working. */
    float motor_motion_margin;     /* Motion margin when motor working. */
    /* Firmware and hardware. */
    uint8_t device_serial_number[9];   /* Device serial number. */
    uint8_t device_password[8];        /* Device password. */        
    uint8_t firmware_version[4];        /* Firmware version, format as A.B.C.D. */
    double motor_minlength_voltage;
    double motor_maxlength_voltage;
    uint32_t chip_id[3];
    uint8_t inputduty_switch;   // 输入PWM计算翻转开关
    uint8_t position_switch;    // 电机位置计算翻转开关
    uint8_t calibration_switch; //电机校准开关
    uint8_t bluetooth_switch; // 蓝牙状态开关
}__attribute__((packed));

struct MotionCharacteristicData {
    int n_data_points;
    float x_data[32];
    float y_data[32];
    /* System init flag. */
    uint8_t system_initialized;     /* System init flag. 0 : System not initialize, 0xe1 : System initialized. */
}__attribute__((packed));


extern SystemConfiguration system_configuration;
extern MotionCharacteristicData system_motion_characteristic_data;

class Configurator {
public:
    static bool load();
    static bool sync();
};

#endif
